package com.lfk.justwetools.Component.NewPaint.Graph;

import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;

import com.lfk.justwetools.Component.NewPaint.UserInfo;
import ohos.agp.render.Path;
import ohos.agp.utils.Color;


/**
 * Created by liufengkai on 15/10/20.
 */
public class DrawBase {
    protected Path mPath;
    protected Paint mPaint;
    protected Paint mEraserPaint;
    protected float mX, mY;

//    protected OnPathListener listener;

    public DrawBase() {
        mPath = new Path();
        mPaint = new Paint();
        mEraserPaint = new Paint();
        Init_Paint(UserInfo.PaintColor,UserInfo.PaintWidth);
        Init_Eraser(UserInfo.EraserWidth);
    }

    // init paint
    private void Init_Paint(int color ,int width){
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setColor(new Color(color));
        mPaint.setStyle(Paint.Style.STROKE_STYLE);
        mPaint.setStrokeJoin(Paint.Join.ROUND_JOIN);
        mPaint.setStrokeCap(Paint.StrokeCap.ROUND_CAP);
        mPaint.setStrokeWidth(width);
    }


    // init eraser
    private void Init_Eraser(int width){
        mEraserPaint.setAntiAlias(true);
        mEraserPaint.setDither(true);
        mEraserPaint.setColor(new Color(0xFF000000));
        mEraserPaint.setStrokeWidth(width);
        mEraserPaint.setStyle(Paint.Style.STROKE_STYLE);
        mEraserPaint.setStrokeJoin(Paint.Join.ROUND_JOIN);
        mEraserPaint.setStrokeCap(Paint.StrokeCap.SQUARE_CAP);
        // The most important
//        mEraserPaint.setXfermode(new PorterDuffMode(PorterDuff.Mode.CLEAR));  // TODO: HOS has Canvas.drawColor(int color, Canvas.PorterDuffMode mode)
    }

    public void setmPaintWidth(float width){
        mPaint.setStrokeWidth(width);
    }

    public void Touch_Down(float x, float y){

    }

    public void Touch_Up(){

    }

    public void Touch_Move(float x, float y){

    }

    public void onDraw(Canvas canvas){

    }


}
